package com.yong.activemq.spring;

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.TextMessage;

@Service
public class SpringMQProduce {
    @Autowired
    private JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("applicationContext.xml");
        SpringMQProduce springMQProduce = (SpringMQProduce) applicationContext.getBean("springMQProduce");
        springMQProduce.jmsTemplate.send(session -> {
            TextMessage textMessage = session.createTextMessage("****spring ActiveMQ 整合 case");
            return textMessage;
        });

        System.out.println("send task ok");
    }
}
